import java.math.BigDecimal;

import Euclid.FloatVarType;
import Euclid.IntVarType;
import Euclid.VarType;
import Euclid.SymbVarType;


public class EuclidExport implements Euclid.EuclidExporter {
	
	public String[] getExports()
	{
		return new String[] { "sin", "cos", "tan" };
	}
	
	/**
	 * Sine
	 * 
	 * @param a
	 * @return
	 */
	public VarType sin(VarType a) {
		if (a instanceof IntVarType)
			return new FloatVarType(new BigDecimal(Math.sin(((IntVarType)a).val.doubleValue())),
					"\\mathrm{sin}(" + a.formula + ")");
		else if (a instanceof FloatVarType)
			return new FloatVarType(new BigDecimal(Math.sin(((FloatVarType)a).val.doubleValue())),
					"\\mathrm{sin}(" + a.formula + ")");
		else if (a instanceof SymbVarType)
			return sin(((SymbVarType)a).val);
		else
			return null;
	}
	
	/**
	 * Cosine
	 * 
	 * @param a
	 * @return
	 */
	public VarType cos(VarType a) {
		if (a instanceof IntVarType)
			return new FloatVarType(new BigDecimal(Math.cos(((IntVarType)a).val.doubleValue())),
					"\\mathrm{cos}(" + a.formula + ")");
		else if (a instanceof FloatVarType)
			return new FloatVarType(new BigDecimal(Math.cos(((FloatVarType)a).val.doubleValue())),
					"\\mathrm{cos}(" + a.formula + ")");
		else if (a instanceof SymbVarType)
			return sin(((SymbVarType)a).val);
		else
			return null;
	}
	
	/**
	 * Tangent
	 * 
	 * @param a
	 * @return
	 */
	public VarType tan(VarType a) {
		if (a instanceof IntVarType)
			return new FloatVarType(new BigDecimal(Math.tan(((IntVarType)a).val.doubleValue())),
					"\\mathrm{tan}(" + a.formula + ")");
		else if (a instanceof FloatVarType)
			return new FloatVarType(new BigDecimal(Math.tan(((FloatVarType)a).val.doubleValue())),
					"\\mathrm{tan}(" + a.formula + ")");
		else if (a instanceof SymbVarType)
			return sin(((SymbVarType)a).val);
		else
			return null;
	}
}
